package	com.sdry.web.controller.jyy.unpack;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.sdry.model.barCodeOperation.BarCodeOperation;
import com.sdry.model.jyy.Workload;
import com.sdry.model.jyy.unpack.JyyUnpacking;
import com.sdry.model.jyy.unpack.UnpackDetal;
import com.sdry.model.llm.DevaningLog;
import com.sdry.model.llm.DevaningWork;
import com.sdry.model.lz.CodeMark;
import com.sdry.model.zc.ZcMaterielAndTrayEntity;
import com.sdry.model.zc.ZcTrayAndLocationEntity;
import com.sdry.service.barCodeOperation.BarCodeOperationService;
import com.sdry.service.jyy.ReceiveDetailService;
import com.sdry.service.jyy.unpack.JingjianUnpackingService;
import com.sdry.service.jyy.unpack.JyyUnpackingService;
import com.sdry.service.jyy.unpack.UnpackDetalService;
import com.sdry.service.llm.CancellingStockDetailService;
import com.sdry.service.llm.DevaningWorkService;
import com.sdry.service.lz.InventoryService;
import com.sdry.service.lz.StockOutOrderService;
import com.sdry.service.zc.ZcBindAndUnbindService;
import com.sdry.utils.DateUtil;
import com.sdry.utils.ResponseUtil;
/**
 *
 *@ClassName: UnpackingController
 *@Description: 
 *@Author jyy
 *@Date 2019-08-20 15:57:31
 *@version 1.0
*/
@Controller
@RequestMapping("/jingJianUnpacking")
public class jingJianUnpackingController{
	@Resource JingjianUnpackingService jingjianUnpackingService;
	@Resource JyyUnpackingService UnpackingService;
	@Resource CancellingStockDetailService cancellingStockDetailService;
	@Resource UnpackDetalService UnpackDetalService;
	@Resource ReceiveDetailService ReceiveDetailService;
	@Resource InventoryService inventoryService;
	@Resource StockOutOrderService stockOutService;
	@Resource UnpackDetalService unpackDetalService;
	@Resource ZcBindAndUnbindService zcBindAndUnbindService;
	@Resource DevaningWorkService devaningWorkService;
	@Resource BarCodeOperationService barCodeOperationService;
	
	
	/**
	 * 根据供应商id，在良品库查询 存在的库存信息
	 * @param customerId 供应商id
	 * @param response 良品库库存集合
	 */
	@RequestMapping("/selectAllGoodOnly")
	public void selectAllGood(JyyInfoGood jyyInfoGood, String materielNum, HttpServletResponse response) {
		
		if(null != materielNum && !"".equals(materielNum)){
			String [] split = materielNum.split(",");
			for(int i = 0; i < split.length; i ++){
				if(i == 0) {
					jyyInfoGood.setMaterielNum1(split[0]);
				}else if(i == 1) {
					jyyInfoGood.setMaterielNum2(split[1]);
				}else if(i == 2) {
					jyyInfoGood.setMaterielNum3(split[2]);
				}else if(i == 3) {
					jyyInfoGood.setMaterielNum4(split[3]);
				}else if(i == 4) {
					jyyInfoGood.setMaterielNum5(split[4]);
				}
			}
		}
		
		//带条件的分页查询 良品库存
		List<JyyInfoGood> list = jingjianUnpackingService.selectPageGoodOnly(jyyInfoGood);
		//统计 良品库库存 总记录数
		Integer total = jingjianUnpackingService.selectCountGoodOnly(jyyInfoGood);
		
		JsonConfig jsonConfig = new JsonConfig();
		//创建result
		JSONObject result = new JSONObject();
		//转json数据
		JSONArray jsonArray = JSONArray.fromObject(list, jsonConfig);
		//添加入result
		result.put("code", 0);
		result.put("data", jsonArray);
		result.put("count", total);
		try {
			ResponseUtil.write(response, result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
}
